home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Linux Cubed Series 8: LINUX Games
/
Linux Cubed Series 8 - LINUX Games.iso
/
games
/
muds
/
lpmud312.tar
/
lpmud312
/
make_func.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-01-11
|
22KB
|
812 lines
#ifndef lint
static char yysccsid[] = "@(#)yaccpar 1.8 (Berkeley) 01/20/90";
#endif
#define YYBYACC 1
#line 2 "make_func.y"
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <fcntl.h>
#include "lint.h"
#include "config.h"
#define FUNC_SPEC "make list_funcs"
#define FUNC_TOKENS "efun_tokens.y"
#define PRE_LANG "prelang.y"
#define POST_LANG "postlang.y"
#define THE_LANG "lang.y"
#define BUFSIZ 1024
#define NELEMS(arr) (sizeof arr / sizeof arr[0])
#define MAX_FUNC 2048 /* If we need more than this we're in trouble! */
int num_buff;
/* For quick sort purposes : */
char *key[MAX_FUNC], *buf[MAX_FUNC], has_token[MAX_FUNC];
int min_arg = -1, limit_max = 0;
/*
* arg_types is the types of all arguments. A 0 is used as a delimiter,
* marking next argument. An argument can have several types.
*/
int arg_types[200], last_current_type;
/*
* Store the types of the current efun. They will be copied into the
* arg_types list if they were not already there (to save memory).
*/
int curr_arg_types[MAX_LOCAL], curr_arg_type_size;
void yyerror PROT((char *));
int yylex();
int yyparse();
int ungetc PROT((int c, FILE *f));
char *type_str PROT((int)), *etype PROT((int)), *etype1 PROT((int)),
*ctype PROT((int));
#ifndef toupper
int toupper PROT((int));
#endif
void fatal(str)
char *str;
{
fprintf(stderr, "%s", str);
exit(1);
}
#line 53 "make_func.y"
typedef union {
int number;
char *string;
} YYSTYPE;
#line 62 "y.tab.c"
#define ID 257
#define VOID 258
#define INT 259
#define STRING 260
#define OBJECT 261
#define MIXED 262
#define UNKNOWN 263
#define DEFAULT 264
#define YYERRCODE 256
short yylhs[] = { -1,
0, 0, 7, 7, 8, 8, 9, 1, 1, 3,
3, 3, 3, 3, 3, 2, 2, 2, 6, 5,
4, 4, 4,
};
short yylen[] = { 2,
0, 2, 1, 0, 3, 0, 8, 1, 2, 1,
1, 1, 1, 1, 1, 0, 1, 3, 1, 1,
1, 3, 3,
};
short yydefred[] = { 1,
0, 10, 11, 12, 15, 13, 14, 0, 0, 2,
0, 9, 3, 0, 0, 0, 20, 0, 0, 21,
17, 0, 0, 0, 0, 0, 23, 0, 18, 0,
22, 5, 7,
};
short yydgoto[] = { 1,
17, 18, 9, 19, 20, 21, 14, 25, 10,
};
short yysindex[] = { 0,
-251, 0, 0, 0, 0, 0, 0, -244, -28, 0,
-241, 0, 0, -23, -31, -27, 0, -38, -106, 0,
0, -26, -37, -31, -19, -251, 0, -234, 0, -35,
0, 0, 0,
};
short yyrindex[] = { 0,
0, 0, 0, 0, 0, 0, 0, 0, -41, 0,
-15, 0, 0, 0, -40, 0, 0, -14, -39, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0,
};
short yygindex[] = { 0,
25, 0, 0, 0, 2, 5, 0, 0, 0,
};
#define YYTABLESIZE 232
short yytable[] = { 8,
16, 19, 8, 16, 19, 24, 2, 3, 4, 5,
6, 7, 11, 12, 16, 13, 15, 26, 22, 27,
28, 30, 32, 33, 4, 8, 6, 31, 29, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 8, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 8, 0, 0, 0, 0,
0, 0, 8, 16, 19, 23, 2, 3, 4, 5,
6, 7,
};
short yycheck[] = { 41,
41, 41, 44, 44, 44, 44, 258, 259, 260, 261,
262, 263, 257, 42, 46, 257, 40, 124, 46, 46,
58, 41, 257, 59, 40, 1, 41, 26, 24, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, 124, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, 257, -1, -1, -1, -1,
-1, -1, 264, 264, 264, 264, 258, 259, 260, 261,
262, 263,
};
#define YYFINAL 1
#ifndef YYDEBUG
#define YYDEBUG 0
#endif
#define YYMAXTOKEN 264
#if YYDEBUG
char *yyname[] = {
"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,"'('","')'","'*'",0,"','",0,"'.'",0,0,0,0,0,0,0,0,0,0,0,"':'","';'",
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
"ID","VOID","INT","STRING","OBJECT","MIXED","UNKNOWN","DEFAULT",
};
char *yyrule[] = {
"$accept : funcs",
"funcs :",
"funcs : funcs func",
"optional_ID : ID",
"optional_ID :",
"optional_default : DEFAULT ':' ID",
"optional_default :",
"func : type ID optional_ID '(' arg_list optional_default ')' ';'",
"type : basic",
"type : basic '*'",
"basic : VOID",
"basic : INT",
"basic : STRING",
"basic : MIXED",
"basic : UNKNOWN",
"basic : OBJECT",
"arg_list :",
"arg_list : typel2",
"arg_list : arg_list ',' typel2",
"typel2 : typel",
"arg_type : type",
"typel : arg_type",
"typel : typel '|' arg_type",
"typel : '.' '.' '.'",
};
#endif
#define yyclearin (yychar=(-1))
#define yyerrok (yyerrflag=0)
#ifdef YYSTACKSIZE
#ifndef YYMAXDEPTH
#define YYMAXDEPTH YYSTACKSIZE
#endif
#else
#ifdef YYMAXDEPTH
#define YYSTACKSIZE YYMAXDEPTH
#else
#define YYSTACKSIZE 500
#define YYMAXDEPTH 500
#endif
#endif
int yydebug;
int yynerrs;
int yyerrflag;
int yychar;
short *yyssp;
YYSTYPE *yyvsp;
YYSTYPE yyval;
YYSTYPE yylval;
short yyss[YYSTACKSIZE];
YYSTYPE yyvs[YYSTACKSIZE];
#define yystacksize YYSTACKSIZE
#line 165 "make_func.y"
struct type {
char *name;
int num;
} types[] = {
{ "void", VOID },
{ "int", INT },
{ "string", STRING },
{ "object", OBJECT },
{ "mixed", MIXED },
{ "unknown", UNKNOWN }
};
FILE *f;
int current_line = 1;
int main(argc, argv)
int argc;
char **argv;
{
int i, fdr, fdw;
char buffer[BUFSIZ + 1];
if ((f = popen(FUNC_SPEC, "r")) == NULL) {
perror(FUNC_SPEC);
exit(1);
}
yyparse();
/* Now sort the main_list */
for (i = 0; i < num_buff; i++) {
int j;
for (j = 0; j < i; j++)
if (strcmp(key[i], key[j]) < 0) {
char *tmp;
int tmpi;
tmp = key[i]; key[i] = key[j]; key[j] = tmp;
tmp = buf[i]; buf[i] = buf[j]; buf[j] = tmp;
tmpi = has_token[i];
has_token[i] = has_token[j]; has_token[j] = tmpi;
}
}
/* Now display it... */
printf("{\n");
for (i = 0; i < num_buff; i++)
printf("%s", buf[i]);
printf("\n};\nint efun_arg_types[] = {\n");
for (i=0; i < last_current_type; i++) {
if (arg_types[i] == 0)
printf("0,\n");
else
printf("%s,", ctype(arg_types[i]));
}
printf("};\n");
pclose(f);
/*
* Write all the tokens out. Do this by copying the
* pre-include portion of lang.y to lang.y, appending
* this information, then appending the post-include
* portion of lang.y. It's done this way because I don't
* know how to get YACC to #include %token files. *grin*
*/
if ((fdr = open(PRE_LANG, O_RDONLY)) < 0) {
perror(PRE_LANG);
exit(1);
}
unlink(THE_LANG);
if ((fdw = open(THE_LANG, O_CREAT | O_WRONLY, 0444)) < 0) {
perror(THE_LANG);
exit(1);
}
while (i = read(fdr, buffer, BUFSIZ))
write(fdw, buffer, i);
close(fdr);
for (i = 0; i < num_buff; i++) {
if (has_token[i]) {
char *str; /* It's okay to mung key[*] now */
for (str = key[i]; *str; str++)
if (islower(*str)) *str = toupper(*str);
sprintf(buffer, "%%token F_%s\n", key[i]);
write(fdw, buffer, strlen(buffer));
}
}
if ((fdr = open(POST_LANG, O_RDONLY)) < 0) {
perror(POST_LANG);
exit(1);
}
while (i = read(fdr, buffer, BUFSIZ))
write(fdw, buffer, i);
close(fdr), close(fdw);
return 0;
}
void yyerror(str)
char *str;
{
fprintf(stderr, "%s:%d: %s\n", FUNC_SPEC, current_line, str);
exit(1);
}
int ident(c)
int c;
{
char buff[100];
int len, i;
for (len=0; isalnum(c) || c == '_'; c = getc(f)) {
buff[len++] = c;
if (len + 1 >= sizeof buff)
fatal("Local buffer in ident() too small!\n");
if (len == sizeof buff - 1) {
yyerror("Too long indentifier");
break;
}
}
(void)ungetc(c, f);
buff[len] = '\0';
for (i=0; i < NELEMS(types); i++) {
if (strcmp(buff, types[i].name) == 0) {
yylval.number = types[i].num;
return types[i].num;
}
}
if (strcmp(buff, "default") == 0)
return DEFAULT;
yylval.string = malloc(strlen(buff)+1);
strcpy(yylval.string, buff);
return ID;
}
char *type_str(n)
int n;
{
int i, type = n & 0xffff;
for (i=0; i < NELEMS(types); i++) {
if (types[i].num == type) {
if (n & 0x10000) {
static char buff[100];
if (strlen(types[i].name) + 3 > sizeof buff)
fatal("Local buffer too small in type_str()!\n");
sprintf(buff, "%s *", types[i].name);
return buff;
}
return types[i].name;
}
}
return "What ?";
}
int yylex1() {
register int c;
for(;;) {
switch(c = getc(f)) {
case ' ':
case '\t':
continue;
case '#':
{
#ifdef sun /* no prototype in <stdio.h> *sigh* */
extern int fscanf PROT((FILE *, char *, ...));
#endif
int line;
char file[2048]; /* does any operating system support
longer pathnames? */
if ( fscanf(f,"%d \"%s\"",&line,file ) == 2 )
current_line = line;
while(c != '\n' && c != EOF)
c = getc(f);
current_line++;
continue;
}
case '\n':
current_line++;
continue;
case EOF:
return -1;
default:
if (isalpha(c))
return ident(c);
return c;
}
}
}
int yylex() {
return yylex1();
}
char *etype1(n)
int n;
{
if (n & 0x10000)
return "T_POINTER";
switch(n) {
case INT:
return "T_NUMBER";
case OBJECT:
return "T_OBJECT";
case STRING:
return "T_STRING";
case MIXED:
return "0"; /* 0 means any type */
default:
yyerror("Illegal type for argument");
}
return "What ?";
}
char *etype(n)
int n;
{
int i;
int local_size = 100;
char *buff = malloc(local_size);
for (i=0; i < curr_arg_type_size; i++) {
if (n == 0)
break;
if (curr_arg_types[i] == 0)
n--;
}
if (i == curr_arg_type_size)
return "0";
buff[0] = '\0';
for(; curr_arg_types[i] != 0; i++) {
char *p;
if (curr_arg_types[i] == VOID)
continue;
if (buff[0] != '\0')
strcat(buff, "|");
p = etype1(curr_arg_types[i]);
/*
* The number 2 below is to include the zero-byte and the next
* '|' (which may not come).
*/
if (strlen(p) + strlen(buff) + 2 > local_size) {
fprintf(stderr, "Buffer overflow!\n");
exit(1);
}
strcat(buff, etype1(curr_arg_types[i]));
}
return buff;
}
char *ctype(n)
int n;
{
static char buff[100]; /* 100 is such a comfortable size :-) */
char *p;
if (n & 0x10000)
strcpy(buff, "TYPE_MOD_POINTER|");
else
buff[0] = '\0';
n &= ~0x10000;
switch(n) {
case VOID: p = "TYPE_VOID"; break;
case STRING: p = "TYPE_STRING"; break;
case INT: p = "TYPE_NUMBER"; break;
case OBJECT: p = "TYPE_OBJECT"; break;
case MIXED: p = "TYPE_ANY"; break;
case UNKNOWN: p = "TYPE_UNKNOWN"; break;
default: yyerror("Bad type!");
}
strcat(buff, p);
if (strlen(buff) + 1 > sizeof buff)
fatal("Local buffer overwritten in ctype()");
return buff;
}
#line 498 "y.tab.c"
#define YYABORT goto yyabort
#define YYACCEPT goto yyaccept
#define YYERROR goto yyerrlab
int
yyparse()
{
register int yym, yyn, yystate;
#if YYDEBUG
register char *yys;
extern char *getenv();
if (yys = getenv("YYDEBUG"))
{
yyn = *yys;
if (yyn >= '0' && yyn <= '9')
yydebug = yyn - '0';
}
#endif
yynerrs = 0;
yyerrflag = 0;
yychar = (-1);
yyssp = yyss;
yyvsp = yyvs;
*yyssp = yystate = 0;
yyloop:
if (yyn = yydefred[yystate]) goto yyreduce;
if (yychar < 0)
{
if ((yychar = yylex()) < 0) yychar = 0;
#if YYDEBUG
if (yydebug)
{
yys = 0;
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
if (!yys) yys = "illegal-symbol";
printf("yydebug: state %d, reading %d (%s)\n", yystate,
yychar, yys);
}
#endif
}
if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
{
#if YYDEBUG
if (yydebug)
printf("yydebug: state %d, shifting to state %d\n",
yystate, yytable[yyn]);
#endif
if (yyssp >= yyss + yystacksize - 1)
{
goto yyoverflow;
}
*++yyssp = yystate = yytable[yyn];
*++yyvsp = yylval;
yychar = (-1);
if (yyerrflag > 0) --yyerrflag;
goto yyloop;
}
if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
{
yyn = yytable[yyn];
goto yyreduce;
}
if (yyerrflag) goto yyinrecovery;
#ifdef lint
goto yynewerror;
#endif
yynewerror:
yyerror("syntax error");
#ifdef lint
goto yyerrlab;
#endif
yyerrlab:
++yynerrs;
yyinrecovery:
if (yyerrflag < 3)
{
yyerrflag = 3;
for (;;)
{
if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
{
#if YYDEBUG
if (yydebug)
printf("yydebug: state %d, error recovery shifting\
to state %d\n", *yyssp, yytable[yyn]);
#endif
if (yyssp >= yyss + yystacksize - 1)
{
goto yyoverflow;
}
*++yyssp = yystate = yytable[yyn];
*++yyvsp = yylval;
goto yyloop;
}
else
{
#if YYDEBUG
if (yydebug)
printf("yydebug: error recovery discarding state %d\n",
*yyssp);
#endif
if (yyssp <= yyss) goto yyabort;
--yyssp;
--yyvsp;
}
}
}
else
{
if (yychar == 0) goto yyabort;
#if YYDEBUG
if (yydebug)
{
yys = 0;
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
if (!yys) yys = "illegal-symbol";
printf("yydebug: state %d, error recovery discards token %d (%s)\n",
yystate, yychar, yys);
}
#endif
yychar = (-1);
goto yyloop;
}
yyreduce:
#if YYDEBUG
if (yydebug)
printf("yydebug: state %d, reducing by rule %d (%s)\n",
yystate, yyn, yyrule[yyn]);
#endif
yym = yylen[yyn];
yyval = yyvsp[1-yym];
switch (yyn)
{
case 4:
#line 73 "make_func.y"
{ yyval.string = ""; }
break;
case 5:
#line 75 "make_func.y"
{ yyval.string = yyvsp[0].string; }
break;
case 6:
#line 75 "make_func.y"
{ yyval.string="0"; }
break;
case 7:
#line 78 "make_func.y"
{
char buff[500];
char f_name[500];
int i;
if (min_arg == -1)
min_arg = yyvsp[-3].number;
if (yyvsp[-5].string[0] == '\0') {
int len;
if (strlen(yyvsp[-6].string) + 1 + 2 > sizeof f_name)
fatal("A local buffer was too small!(1)\n");
sprintf(f_name, "F_%s", yyvsp[-6].string);
len = strlen(f_name);
for (i=0; i < len; i++) {
if (islower(f_name[i]))
f_name[i] = toupper(f_name[i]);
}
has_token[num_buff]=1;
} else {
if (strlen(yyvsp[-5].string) + 1 > sizeof f_name)
fatal("A local buffer was too small(2)!\n");
strcpy(f_name, yyvsp[-5].string);
has_token[num_buff]=0;
}
for(i=0; i < last_current_type; i++) {
int j;
for (j = 0; j+i<last_current_type && j < curr_arg_type_size; j++)
{
if (curr_arg_types[j] != arg_types[i+j])
break;
}
if (j == curr_arg_type_size)
break;
}
if (i == last_current_type) {
int j;
for (j=0; j < curr_arg_type_size; j++) {
arg_types[last_current_type++] = curr_arg_types[j];
if (last_current_type == NELEMS(arg_types))
yyerror("Array 'arg_types' is too small");
}
}
sprintf(buff, "{\"%s\",%s,%d,%d,%s,%s,%s,%d,%s},\n",
yyvsp[-6].string, f_name, min_arg, limit_max ? -1 : yyvsp[-3].number, ctype(yyvsp[-7].number),
etype(0), etype(1), i, yyvsp[-2].string);
if (strlen(buff) > sizeof buff)
fatal("Local buffer overwritten !\n");
key[num_buff] = (char *) malloc(strlen(yyvsp[-6].string) + 1);
strcpy(key[num_buff], yyvsp[-6].string);
buf[num_buff] = (char *) malloc(strlen(buff) + 1);
strcpy(buf[num_buff], buff);
num_buff++;
min_arg = -1;
limit_max = 0;
curr_arg_type_size = 0;
}
break;
case 9:
#line 134 "make_func.y"
{ yyval.number = yyvsp[-1].number | 0x10000; }
break;
case 16:
#line 138 "make_func.y"
{ yyval.number = 0; }
break;
case 17:
#line 139 "make_func.y"
{ yyval.number = 1; if (yyvsp[0].number) min_arg = 0; }
break;
case 18:
#line 140 "make_func.y"
{ yyval.number = yyvsp[-2].number + 1; if (yyvsp[0].number) min_arg = yyval.number - 1; }
break;
case 19:
#line 143 "make_func.y"
{
yyval.number = yyvsp[0].number;
curr_arg_types[curr_arg_type_size++] = 0;
if (curr_arg_type_size == NELEMS(curr_arg_types))
yyerror("Too many arguments");
}
break;
case 20:
#line 151 "make_func.y"
{
if (yyvsp[0].number != VOID) {
curr_arg_types[curr_arg_type_size++] = yyvsp[0].number;
if (curr_arg_type_size == NELEMS(curr_arg_types))
yyerror("Too many arguments");
}
yyval.number = yyvsp[0].number;
}
break;
case 21:
#line 160 "make_func.y"
{ yyval.number = (yyvsp[0].number == VOID && min_arg == -1); }
break;
case 22:
#line 161 "make_func.y"
{ yyval.number = (min_arg == -1 && (yyvsp[-2].number || yyvsp[0].number == VOID));}
break;
case 23:
#line 162 "make_func.y"
{ yyval.number = min_arg == -1 ; limit_max = 1; }
break;
#line 756 "y.tab.c"
}
yyssp -= yym;
yystate = *yyssp;
yyvsp -= yym;
yym = yylhs[yyn];
if (yystate == 0 && yym == 0)
{
#if YYDEBUG
if (yydebug)
printf("yydebug: after reduction, shifting from state 0 to\
state %d\n", YYFINAL);
#endif
yystate = YYFINAL;
*++yyssp = YYFINAL;
*++yyvsp = yyval;
if (yychar < 0)
{
if ((yychar = yylex()) < 0) yychar = 0;
#if YYDEBUG
if (yydebug)
{
yys = 0;
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
if (!yys) yys = "illegal-symbol";
printf("yydebug: state %d, reading %d (%s)\n",
YYFINAL, yychar, yys);
}
#endif
}
if (yychar == 0) goto yyaccept;
goto yyloop;
}
if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
yystate = yytable[yyn];
else
yystate = yydgoto[yym];
#if YYDEBUG
if (yydebug)
printf("yydebug: after reduction, shifting from state %d \
to state %d\n", *yyssp, yystate);
#endif
if (yyssp >= yyss + yystacksize - 1)
{
goto yyoverflow;
}
*++yyssp = yystate;
*++yyvsp = yyval;
goto yyloop;
yyoverflow:
yyerror("yacc stack overflow");
yyabort:
return (1);
yyaccept:
return (0);
}